/**
 * 
 */
package com.yidu.drug.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.drug.common.Page;
import com.yidu.drug.dao.InventoryRecordModelMapper;
import com.yidu.drug.model.InventoryRecordModel;
import com.yidu.drug.service.InventoryRecordService;

/**
 * 库存记录Service实现类
 * @author tanglei
 * @date 2018年8月23日 上午11:37:18
 * @version 1.0
 */
@Service
public class InventoryRecordServiceImpl implements InventoryRecordService{
	//注入库存记录Dao
	@Resource
	private InventoryRecordModelMapper inventoryRecordDao;
	
	@Override
	public int deleteByPrimaryKey(String irId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(InventoryRecordModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertSelective(InventoryRecordModel record) {
		// TODO Auto-generated method stub
		return inventoryRecordDao.insertSelective(record);
	}

	@Override
	public InventoryRecordModel selectByPrimaryKey(String irId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(InventoryRecordModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKey(InventoryRecordModel record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/**
	 * 根据分公司ID查询库存记录
	 * @param record 传入一个库存记录
	 * @return 返回一map集合
	 */
	@Override
	public Map<String, Object> findByFilId(InventoryRecordModel record) {
		//创建一个分页对象
		Page page = new Page();
		//给分页对象里面的页数属性赋值，数值为库存明细对象里面的页数数值
		page.setPage(Integer.valueOf(record.getPage()));
		//给分页对象里面的每页显示行数的属性赋值，数值为库存明细对象里面的每页显示行数数值
		page.setRows(Integer.valueOf(record.getLimit()));
		//给库存明细里面的分页对象属性赋值
		record.setPages(page);
		//创建一个map集合
		Map<String,Object> map = new HashMap<String,Object>();
		//调用库存记录Dao里面的根据分公司ID查询库存记录的方法
		List<InventoryRecordModel> list = inventoryRecordDao.findByFilId(record);
		//调用库存记录Dao里面的查询总行数的方法
		Long count = inventoryRecordDao.findRows(record);
		//给map集合赋值
		map.put("code", 0);
		map.put("msg", "");
		map.put("count", count);
		map.put("data", list);
		//返回map集合
		return map;
	}

}
